package com.cloud.business.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cloud.business.dao.Business_infoMapper;
import com.cloud.business.entity.Account_businessInfo;
import com.cloud.business.service.businessService;
import com.cloud.commonapi.model.Business_info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * author : 黄永佳
 * create : 2019/9/26 0026 10:20
 * modified :
 * 功能 :
 **/
@Service
public class businessServiceImpl implements businessService {
    @Autowired
    Business_infoMapper business_infoMapper;
    @Override
    public int insertBusiness(Business_info business_info) {
        return business_infoMapper.insert(business_info);
    }

    @Override
    public Account_businessInfo selectById(int id) {
        return business_infoMapper.selectById(id);
    }

    @Override
    public List<Account_businessInfo> findAll() {
        return business_infoMapper.findAll();
    }

    @Override
    public List<Account_businessInfo> findByKeyword(String keyword) {
        return business_infoMapper.selectByKeyword(keyword);
    }

    @Override
    public Business_info findByOrder(int id) {
        return business_infoMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteById(int id) {
        return business_infoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Business_info business_info) {
        return business_infoMapper.updateByPrimaryKeySelective(business_info);
    }

    @Override
    public List<Account_businessInfo> selectByAccountId(int accountId) {
        return business_infoMapper.selectByAccountId(accountId);
    }

    @Override
    public IPage<Account_businessInfo> selectPage(Account_businessInfo account_businessInfo,int page, int pageSize) throws RuntimeException{
        try{
            Page<Account_businessInfo> p=new Page<>(page,pageSize);
            p.setRecords(business_infoMapper.selectPageExt(p,account_businessInfo));
            return p;
        } catch (Exception e){
            throw new RuntimeException(e.getMessage());
        }
    }

    @Override
    public List<Business_info> selectByOrder(int accountId) {
        return business_infoMapper.selectByOrder(accountId);
    }
}
